// ajax封装
function ajax(Type, Url, Data, DataType, Success, Error, Cache) {
    var type = Type || 'post';//请求类型
    var dataType = DataType || 'json';//接收数据类型
    var cache = Cache || false;//浏览器历史缓存
    var success = Success || function (data) {
        if (data.status == 200) {
            location.reload();
        } else {
            layer.alert(data.message, {title: '错误信息', icon: 0});
        }
    };
    var error = Error || function (data) {
        setTimeout(function () {
            if (data.status == 404) {
                layer.msg('请求失败，请求未找到', {icon: 2});
            } else if (data.status == 403) {
                layer.msg('您没有该操作权限', {icon: 2});
            } else if (data.status == 302) {
                layer.alert('登录失效！', {
                    icon: 0, time: 2000, skin: 'layui-layer-warn', anim: 1, closeBtn: 1,
                    end: function () {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                        location.reload();
                    }
                });
            } else if (data.status == 503) {
                layer.msg('请求失败，服务器内部错误', {icon: 2});
            } else if (data.status == 500) {
                layer.msg('请求失败,服务器内部错误', {icon: 2});
            }else if(data.responseText.indexOf("文明办-后台登录")>0){
                layer.alert('登录失效！', {
                    icon: 0, time: 2000, skin: 'layui-layer-warn', anim: 1, closeBtn: 1,
                    end: function () {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                        location.reload();
                    }
                });
            }
        }, 500);
    };

    $.ajax({
        'url': Url,
        'data': Data,
        'type': type,
        'dataType': dataType,
        'async': false,
        'cache': cache,
        'success': success,
        'error': error,
        'beforeSend': function () {
            // show_msg("加载中...",false);
        }
    });
}